/**
 * Created by ACER on 2017/4/9.
 */

app.controller("condition", function ($scope, $http) {

    console.log('task-condition controller is this page now.');

    var token = localStorage.getItem('token');
    var condition = sessionStorage.getItem('condition');
    if (!token) {
        $.alert('请先登录', function () {
            location.href = '#login';
        });
        return;
    }

    // 条件选择中conditionSex的值 0：男 1：女
    $scope.choiceOfCondition = [null,0,1];

    $scope.taskInfo = {};

    $scope.getSavedCondition = function () {
        var taskStr = sessionStorage.getItem('task-pre-to-create');
        if (taskStr == null) {
            return;
        }
        $scope.taskInfo = JSON.parse(taskStr);
    };

    $scope.saveTask = function () {
        if ($scope.taskInfo == null) {
            return;
        }
        var taskStr = JSON.stringify($scope.taskInfo);
        sessionStorage.setItem('task-pre-to-create',taskStr);
        history.back();
    };


});

